blob: 8d48611336d33a9570d6f05e8028850c5e7914ed (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
import { cookies } from "next/headers"
import { Shell } from "@/components/shell"
import DocumentContainer from "@/components/documents/document-container"
import { getVendorProjectsAndContracts } from "@/lib/vendor-data/services"
import { getVendorDocumentLists } from "@/lib/vendor-document/service"
import VendorDocumentsClient from "@/components/documents/vendor-docs.client"
import VendorDocumentListClient from "@/components/document-lists/vendor-doc-list-client"
import { authOptions } from "@/app/api/auth/[...nextauth]/route";
import { getServerSession } from "next-auth";
// Layout 컴포넌트는 서버 컴포넌트입니다
export default async function VendorDocuments({
children,
}: {
children: React.ReactNode
}) {
const session = await getServerSession(authOptions)
const vendorId = session?.user.companyId
// const vendorId = "17"
const idAsNumber = Number(vendorId)
const projects = await getVendorProjectsAndContracts(idAsNumber);
const filteredProjects = projects.filter(v=>v.projectType === "plant")
// 레이아웃 설정 쿠키 가져오기
// Next.js 15에서는 cookies()가 Promise를 반환하므로 await 사용
const cookieStore = await cookies()
// 이제 cookieStore.get() 메서드 사용 가능
const layout = cookieStore.get("react-resizable-panels:layout:mail")
const collapsed = cookieStore.get("react-resizable-panels:collapsed")
const defaultLayout = layout ? JSON.parse(layout.value) : undefined
const defaultCollapsed = collapsed ? JSON.parse(collapsed.value) : undefined
return (
<Shell className="gap-2">
<VendorDocumentListClient projects={filteredProjects}>
{children}
</VendorDocumentListClient>
</Shell>
)
}
|